﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>大厅等候</title>
    <link href="css.css" rel="stylesheet" />
    <script src="jquery.min.js"></script>
</head>
<body>
<div class="main">
    <div class="title">
        <div class="left" id="hsptl_name">成都市第一人民医院</div>
        <div class="middle"><span id="triage_name">正在读取信息，请稍后...</span></div>
        <div class="right">
            <span  id="now_time"></span><br />
            <span id="now_date"></span>
        </div>
    </div>
    <!--<div class="tab_title">
        <div class="left">诊室</div>
        <div class="middle">正在就诊</div>
        <div class="right">等候就诊</div>
    </div>
    <ul id="list">
       
    </ul>-->

    <div class="qmj">
        <div class="left">&nbsp;</div>
        <div class="right">
            <div class="list" id="list">
                
            </div>
            <div class="call" id="call">
                
            </div>
        </div>
    </div>
    <div class="bottom">温馨提示：请保管好您的随身物品,耐心等候！！！</div>
</div>
 
</body>
</html>
<script type="text/javascript">
    function ShowTime() {
        try {
            var datetime = window.Callobject.getDateTime();
            var year = datetime.split(' ')[0].split('-')[0].toString() + '年' + datetime.split(' ')[0].split('-')[1].toString() + '月' + datetime.split(' ')

            [0].split('-')[2].toString() + '日';
            var week = "　星期" + "日一二三四五六".charAt(datetime.split(' ')[2].toString().trim().replace('7', '0'));
            var time = datetime.split(' ')[1].toString();
            $("#now_date").html(year + week);
            $("#now_time").html(time.split(':')[0] + ':' + time.split(':')[1]);
        }
        catch (ex) { }
    }
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    //var ip = getUrlParam("ip");
   
    
    function GetList() {
        
        var html = "";
        $.ajax({
            type: "GET",
            async: false,
            url: "/call_patient/list_patient_wait",
            contentType: "application/text;charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {
                $("#list").html("");
                $("#triage_name").html(data.fztname);
                $.each(data.list, function (i, item) {
                    if (i % 2 == 0)
                        html += "<div class='zs_list'><ul><li class='bg'>" + data.list[i].zsmc + "</li><li class='bg'>" + data.list[i].dh_name0 + "</li><li class='bg'>" + data.list[i].dh_name1 + "</li><li class='bg'>" + data.list[i].dh_name2 + "</li></ul></div>";
                    else
                        html += "<div class='zs_list'><ul><li>" + data.list[i].zsmc + "</li><li>" + data.list[i].dh_name0 + "</li><li>" + data.list[i].dh_name1 + "</li><li>" + data.list[i].dh_name2 + "</li></ul></div>";
                });
                $("#list").html(html);
            },
            error: function () {
                $("#triage_name").html("未知");
            }
        });
    }

    function PagerCall() {

        $.ajax({
            type: "GET",
            url: "/patientQueue/list_patient_call",
            contentType: "application/text;charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {
                var k = 0;
                for (var i = 0; i < data.list.length; i++) {
                    //$.each(data.list, function (j, item) {
                    //    //if (item.hjzt == 1) {
                    var item = data.list[i];
                    
                    var t = ("请 " + item.patient_name + " 到" + item.jhqmc + "就诊。").length * 400;
                    setTimeout("showtips(" + t + ", '" + item.patient_name + "','" + item.jhqmc + "','" + item.register_id + "')", k);
                    
                    k = k + t;
                    
                }
                setTimeout(PagerCall, k);
            },
            error: function () {
                
            }
        });
    }
    function showtips(t, name, jhqmc, id) {
        $("#call").html("请 " + id + "号" + name + " 到" + jhqmc + "就诊");
        var callText = "<?xml version=\"1.0\" encoding=\"GB18030\"?>"
            + "<Contents><Content>"
            + "<Voice Num=\"1\" Speed=\"1000\" digitMode=\"1\">"
            + "请 " + id + "号" +name + " 到" + jhqmc + "就诊。"
            + "</Voice>"
            + "</Content></Contents>";
        window.Callobject.playVoice(callText)
    }
    GetList();
    PagerCall();
    ShowTime();
    
    window.setInterval(GetList, 2000);
    window.setInterval(ShowTime, 5000);
</script>